<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<?php
        
        require_once '../inc/config.php';
        require_once '../inc/connexion.php';
?>
<html>
    <head>
        <meta charset="utf-8">
        <title>Liste des entreprises</title>
        <link href="../bootstrap/css/bootstrap.css" type="text/css" rel="stylesheet">
        <link href="../css/style.css" type="text/css" rel="stylesheet">
    </head>
    <body>
         <a id="haut"></a>
<?php require_once "../inc/css_js_bootstrap/css_js_bootstrap.php"; ?>
        <?php
        require_once '../inc/menus/menu_principal.php';
        
        if(isset($_GET["tous"])) :
        $sql = "SELECT * FROM entreprises";
        
        elseif(isset($_GET["croissant"])) :
        $sql = "SELECT * FROM entreprises ORDER BY raison_sociale ASC";
        
        elseif(isset($_GET["decroissant"])) :
        $sql = "SELECT * FROM entreprises ORDER BY raison_sociale DESC";
        
        else :
             $sql = "SELECT * FROM entreprises"; 
        
        endif;
      
        $envoi_requete = mysqli_query($connexion_serveur, $sql);
        
        $nbre= mysqli_num_rows($envoi_requete);
        
     ?> 
        <br><div id="div2">
                <h3>LISTE DES ENTREPRISES</h3>
                Nombre d'entreprises affichées :  <span><?php echo $nbre; ?> </span>
        </div><br>
        <div id="div2">
                <form>
                <input class="btn btn-default" type="button" value="Afficher tous" onclick="window.location.href='../entreprises/liste_entreprises.php?tous'">
                <input class="btn btn-default" type="button" value="Tri croissant par raison sociale" onclick="window.location.href='../entreprises/liste_entreprises.php?croissant'">
                <input class="btn btn-default" type="button" value="Tri décroissant par raison sociale" onclick="window.location.href='../entreprises/liste_entreprises.php?decroissant'">
            </form>
            <br>
        
             </div>
<?php        
while($resultats = mysqli_fetch_assoc($envoi_requete)) {
                ?>
            <div id="div1">
        <table>
            <tr>
                <td class="col1"> n°</td>
                <td class="col2"><?php echo $resultats['id'];?></td>
            </tr>
            <tr>
                 <td class="col1">Raison sociale</td>
                 <td class="col2"><a href="../contacts/liste_contacts.php?id_entreprise=<?php echo $resultats['id'];?>"><?php echo $resultats['raison_sociale'];  ?></a></td>
            </tr>
            <tr>
                 <td class="col1">Adresse</td>
                 <td class="col2"><?php echo $resultats['adresse'];  ?></td>
            </tr>
            <tr>
                 <td class="col1">Téléphone</td>
                 <td class="col2"><?php echo $resultats['telephone'];  ?></td>
            </tr>
            <tr>
                 <td class="col1">Fax</td>
                 <td class="col2"><?php echo $resultats['fax'];  ?></td>
            </tr>
            <tr>
                 <td class="col1">Email</td>
                 <td class="col2"><?php echo $resultats['email'];  ?></td>
            </tr>
            <tr>
                 <td class="col1">Observations</td>
                 <td class="col2"><?php echo $resultats['observations'];  ?></td>
            </tr>
            <tr>
                <td class="col1"></td>
                <td class="col2"><a href="../entreprises/modifier_entreprises.php?ids=<?php echo $resultats['id'];?>" >Modifier</a></td>
            </tr>
        </table>
                <br>
            </div>    
            <?php
            }
        ?>
 <a href="#haut">Haut de page</a>
    </body>
</html>
